package com.xingchi.tornado.basic;

import lombok.Getter;

/**
 * 错误码
 *
 * @author xingchi
 * @date 2025/6/4 21:42
 */
@Getter
public enum ErrorCode implements BaseCode {

    SUCCESS(0, "成功"),
    FAIL(-1, "失败"),

    // 系统级错误：1000-1999
    SYSTEM_ERROR(1000, "系统错误"),
    SERVICE_UNAVAILABLE(1001, "服务不可用"),
    METHOD_NOT_ALLOWED(1002, "请求方法不允许"),
    REQUEST_TIMEOUT(1003, "请求超时"),
    REQUEST_TOO_LARGE(1004, "请求数据过大"),
    TOO_MANY_REQUESTS(1005, "请求频率过高"),

    // 用户错误：2000-2999
    USER_NOT_FOUND(2000, "用户不存在"),
    USER_ALREADY_EXISTS(2001, "用户已存在"),
    USERNAME_OR_PASSWORD_ERROR(2002, "用户名或密码错误"),
    USER_TOKEN_EXPIRED(2003, "用户令牌已过期"),
    USER_TOKEN_INVALID(2004, "用户令牌无效"),
    USER_ACCESS_DENIED(2005, "用户权限不足"),
    INVALID_VERIFICATION_CODE(2006, "验证码无效"),
    LOGIN_FAILED(2007, "登录失败"),
    USER_OPERATION_FAILED(2008, "用户操作失败"),

    // 参数校验错误：5000-5999
    PARAM_IS_INVALID(4000, "参数无效"),
    PARAM_IS_BLANK(4001, "参数为空"),
    PARAM_TYPE_ERROR(4002, "参数类型错误"),
    PARAM_NOT_COMPLETE(4003, "参数缺失"),

    // 文件操作错误：6000-6999
    FILE_NOT_FOUND(5000, "文件不存在"),
    FILE_UPLOAD_FAILED(5001, "文件上传失败"),
    FILE_DELETE_FAILED(5002, "文件删除失败"),
    FILE_DOWNLOAD_FAILED(5003, "文件下载失败"),
    FILE_TYPE_NOT_ALLOWED(6004, "文件类型不允许"),
    FILE_SIZE_EXCEEDED(5005, "文件大小超出限制"),
    FILE_STREAM_GET_FAILED(5006, "文件流获取失败"),
    ALIYUN_OSS_CLIENT_LOAD_FAIL(5100, "阿里云OSS客户端加载失败"),

    // 短信相关操作
    SMS_SEND_FAILED(7000, "短信发送失败"),
    SMS_VERIFICATION_FAILED(7001, "短信验证失败"),
    SMS_VERIFICATION_CODE_EXPIRED(7002, "短信验证码已过期"),
    SMS_VERIFICATION_CODE_INVALID(7003, "短信验证码无效"),
    SMS_VERIFICATION_CODE_NOT_MATCH(7004, "短信验证码不匹配"),
    SMS_VERIFICATION_CODE_NOT_FOUND(7005, "短信验证码未找到"),
    SMS_VERIFICATION_CODE_EXCEEDED(7006, "短信验证码已超出限制"),
    SMS_VERIFICATION_CODE_NOT_EXIST(7007, "短信验证码不存在"),

    // 其它业务错误：8000-8999
    OPERATION_FAILED(9000, "操作失败"),
    DATA_NOT_FOUND(9001, "数据不存在"),
    DUPLICATE_OPERATION(9002, "重复操作"),
    OPERATION_TOO_FREQUENT(9003, "操作过于频繁"),
    BUSINESS_EXCEPTION(9004, "业务异常"),
    UNKNOWN_ERROR(9999, "未知错误");
    ;
    private final Integer code;
    private final String message;

    ErrorCode(Integer code, String message) {
        this.code = code;
        this.message = message;
    }
}
